	<div id="footer">
	<center>Copyright @ Nova ITech, Ltd, 2003 - 2013</center>
	</div>
<style>
		#dialog-form-login label, #dialog-form-login input { display:block; }
		#dialog-form-login input.text { margin-bottom:12px; width:95%; padding: .4em; }
		#dialog-form-login fieldset { padding:0; border:0; margin-top:25px; }
		#dialog-form-login h1 { font-size: 1.2em; margin: .6em 0; }
		#login-user{
			cursor:pointer;
		}
		#dialog-form-login .ui-dialog .ui-state-error { padding: .3em; }
		#dialog-form-login .validateTips { border: 1px solid transparent; padding: 0.3em; }
		
		#dialog-form-check-pass label, #dialog-form-check-pass input { display:block; }
		#dialog-form-check-pass input.text { margin-bottom:12px; width:95%; padding: .4em; }
		#dialog-form-check-pass fieldset { padding:0; border:0; margin-top:25px; }
		#dialog-form-check-pass h1 { font-size: 1.2em; margin: .6em 0; }
		#dialog-form-check-pass .ui-dialog .ui-state-error { padding: .3em; }
		#dialog-form-check-pass .validateTips { border: 1px solid transparent; padding: 0.3em; }
	</style>
	<script>
	$(function() {
		$("a.preventDefault").click(function(event){
				event.preventDefault();
				alert("fsfs");
			});
		// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
		$( "#dialog:ui-dialog" ).dialog( "destroy" );
		
		var User_ID = $( "#User_ID" ),
			//email = $( "#email" ),
			password = $( "#matkhau" ),
			allFields = $( [] ).add( User_ID ).add( password ),
			tips = $( ".validateTips" ),
			check_password = $("#check_matkhau"),
			check_User_ID = $("#check_User_ID"),
			check_allFields = $( [] ).add( check_User_ID ).add( check_password );

		function updateTips( t ) {
			tips
				.text( t )
				.addClass( "ui-state-highlight" );
			setTimeout(function() {
				tips.removeClass( "ui-state-highlight", 1500 );
			}, 500 );
		}

		function checkLength( o, n, min, max ) {
			if ( o.val().length > max || o.val().length < min ) {
				o.addClass( "ui-state-error" );
				if(o.val().length==0){
					updateTips( "Vui lòng điền thông tin "+ n+".");
				}else{
				updateTips( "Length of " + n + " must be between " +
					min + " and " + max + "." );
				}
				return false;
			} else {
				return true;
			}
		}

		function checkRegexp( o, regexp, n ) {
			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass( "ui-state-error" );
				updateTips( n );
				return false;
			} else {
				return true;
			}
		}
		
		$( "#dialog-form-login" ).dialog({
			autoOpen: false,
			height: 420,
			width: 350,
			modal: true,
			buttons: {
				"Đăng nhập": function() {
					var bValid = true;					
					allFields.removeClass( "ui-state-error" );

					bValid = bValid && checkLength( User_ID, "tên đăng nhập", 1, 16 );
					//bValid = bValid && checkLength( email, "email", 6, 80 );
					bValid = bValid && checkLength( password, "mật khẩu", 1, 16 );

					//bValid = bValid && checkRegexp( User_ID, /^[a-z]([0-9a-z_])+$/i, "User ID may consist of a-z, 0-9, underscores, begin with a letter." );
					// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
					//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );
					//process login
					if(bValid){
						// var url_cur=document.URL;
						// url_cur=url_cur.replace(/#/gi, "");
						// alert(url_curl);
						$.ajax({
						  type: "POST",
						  url: "<?php echo base_url();?>index.php/functions/check_login",
						  data: {
							tendangnhap:$( "#User_ID" ).val(),
							matkhau:$( "#matkhau" ).val()//,
							// url_curl:url_cur
							},
						  cache: false,
						  success: function(data){
							var R = eval('(' + data + ')');  
							if(R.login==1){								
								$( "#dialog-form-login" ).dialog( "close" );
								//alert("Đăng nhập thành công!");	
								if(R.url_login)
									location.href=R.url_login;
								else
									location.href="<?php echo current_url();?>";
							}
							else
								updateTips( R.error );
						  }
						});
					}					
				},
				"Hủy": function() {
					$( this ).dialog( "close" );
				}
			},
			close: function() {
				allFields.val( "" ).removeClass( "ui-state-error" );
			}
		});

		$( "#login-user" ).click(function() {
				$( "#dialog-form-login" ).dialog( "open" );
				$("#matkhau").keyup(function (e) {
					if (e.keyCode == 13) {
						$(".ui-button-text").each(function(){
							if($(this).html()=="Đăng nhập") $(this).click();
						});
					}
				});
			});	
			
		$( "#dialog-form-check-pass" ).dialog({
			autoOpen: false,
			height: 420,
			width: 350,
			modal: true,
			buttons: {
				"Go": function() {
					var bValid = true;					
					check_allFields.removeClass( "ui-state-error" );
					bValid = bValid && checkLength( check_User_ID, "tên đăng nhập", 1, 16 );
					bValid = bValid && checkLength( check_password, "mật khẩu", 1, 16 );
					if(bValid){
						$.ajax({
						  type: "POST",
						  url: "<?php echo base_url();?>index.php/functions/check_pass",
						  data: {
							tendangnhap:$( "#check_User_ID" ).val(),
							matkhau:$( "#check_matkhau" ).val(),
							gotourl:$("#check_pass_url").val()
							},
						  cache: false,
						  success: function(data){
							var R = eval('(' + data + ')');  
							if(R.login==1){		
								if(R.gotourl!="")
									location.href=R.gotourl;
							}
							else
								updateTips( R.error );
						  }
						});
					}					
				},
				"Hủy": function() {
					$( this ).dialog( "close" );
					return false;
				}
			},
			close: function() {
				check_allFields.val( "" ).removeClass( "ui-state-error" );
				return false;
			}
		});
		$( ".check-pass" ).click(function() {
				$( "#dialog-form-check-pass" ).dialog( "open" );
				$("#check_matkhau").keyup(function (e) {
					if (e.keyCode == 13) {
						$(".ui-button-text").each(function(){
							if($(this).html()=="Kiem tra mat khau") $(this).click();
						});
					}
				});
		});	

	});
	
	</script>
<div class="login-user">

<div id="dialog-form-login" title="Đăng nhập">
	<p class="validateTips">Điền đầy đủ thông tin bên dưới.</p>

	<form>
	<fieldset>
		<label for="User_ID">Tên đăng nhập</label>
		<input type="text" name="User_ID" id="User_ID" placeholder="Tên đăng nhập" class="text ui-widget-content ui-corner-all" />
		<!--<label for="email">Email</label>
		<input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />-->
		<label for="matkhau">Mật khẩu</label>
		<input type="password" name="matkhau" id="matkhau" placeholder="Mật khẩu" value="" class="text ui-widget-content ui-corner-all" />
		<center> </center>
	</fieldset>
	</form>
</div>

</div><!-- End login-user -->
<div id="check-pass">

<div id="dialog-form-check-pass" title="Kiem tra mat khau">
	<p class="validateTips">Điền đầy đủ thông tin bên dưới.</p>

	<form>
	<fieldset>
		<label for="User_ID">Tên đăng nhập</label>
		<input type="text" name="check_User_ID" id="check_User_ID" placeholder="Tên đăng nhập" class="text ui-widget-content ui-corner-all" />
		<label for="matkhau">Mật khẩu</label>
		<input type="password" name="check_matkhau" id="check_matkhau" placeholder="Mật khẩu" value="" class="text ui-widget-content ui-corner-all" />
		<input type="hidden" name="check_pass_url" id="check_pass_url" value=""/>
	</fieldset>
	</form>
</div>

</div><!-- End check pass -->